home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1984 June / 1984-06.d64 / random numbers (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  2KB  |  107 lines

  1. 1 print"[147] press r[146] to randomize."
  2. 2 geta$:ifa$=""then2
  3. 3 ifa$="r"thenx=rnd(-ti)
  4. 5 poke56,27:clr:print"[147] please wait..."
  5. 7 b=7168:c=7679:fora=btoc:pokea,0:next
  6. 10 b=885:c=947:fora=btoc:readd:pokea,d:next
  7. 20 print"[147] v[146]ic or 64?"
  8. 25 print" press v[146] for vic"
  9. 26 print" return[146] for 64."
  10. 30 geta$:ifa$=""then30
  11. 35 ifa$<>"v"then50
  12. 40 poke888,39:poke892,148
  13. 50 print"[147] press f1[146] to test"
  14. 51 print" random seeds."
  15. 60 print" press f3[146] to test"
  16. 61 print" basic rnd[146] command."
  17. 70 geta$:ifa$=""then70
  18. 80 ifa$="[133]"thengoto1000
  19. 90 ifa$="[134]"thengoto2000
  20. 100 goto50
  21. 885 data165,197,201,4,240,55,32,151
  22. 893 data224,165,143,133,251,169,254,133
  23. 901 data253,169,27,133,254,160,255,24
  24. 909 data165,253,105,2,133,253,165,254
  25. 917 data105,0,133,254,200,196,251,208
  26. 925 data238,160,0,24,177,253,105,1
  27. 933 data145,253,200,177,253,105,0,145
  28. 941 data253,201,255,208,195,96,0,0
  29. 1000 print"[147] press 1-5 to test"
  30. 1010 print" random seeds."
  31. 1020 print" press    test byte:[146]"
  32. 1030 print"   1         139"
  33. 1040 print"   2         140"
  34. 1050 print"   3         141"
  35. 1060 print"   4         142"
  36. 1070 print"   5         143"
  37. 1080 geta$:ifa$=""then1080
  38. 1090 a=val(a$):ifa<1ora>5then1000
  39. 1100 poke895,138+a
  40. 1110 print"[147] testing random seed"
  41. 1120 print" byte ";a+138;"[157]."
  42. 1130 print" press f1[146] to stop."
  43. 1140 sys885:goto3000
  44. 2000 poke945,4:poke946,169:poke947,255:poke948,133:poke949,176:poke950,96
  45. 2002 fora=891to897:pokea,234:next
  46. 2005 print"[147] testing basic rnd[146]"
  47. 2010 print" command."
  48. 2020 print" enter number range:"
  49. 2030 print" (0 - 255)"
  50. 2035 print" enter two numbers"
  51. 2036 print" separated by a comma."
  52. 2040 inputa,b
  53. 2050 ifa<0ora>255then2000
  54. 2060 ifb<0orb>255then2000
  55. 2070 print"[147] testing rnd[146] command."
  56. 2080 print" range= ";a;"-";b
  57. 2090 print" press f1[146] to stop."
  58. 2100 x=251:y=176:z=255:r=(abs(a-b))+1:pokey,0
  59. 2110 ifa<bthenl=a
  60. 2120 ifb<athenl=b
  61. 2130 pokex,int((rnd(1)*r)+l):sys885:ifpeek(y)=zthen3000
  62. 2140 goto2130
  63. 3000 poke198,0:gosub3500
  64. 3010 b=7168:c=7678:q=256:l=20:fora=btocstep2
  65. 3020 printct,peek(a)+q*peek(a+1):n=n+1:ct=ct+1:ifn=>lthengosub3200
  66. 3030 next
  67. 3100 print"  (press any key)"
  68. 3110 geta$:ifa$=""then3110
  69. 3120 goto4000
  70. 3200 n=0
  71. 3210 geta$:ifa$=""then3210
  72. 3220 gosub3500:return
  73. 3500 print"[147]number","count":return
  74. 4000 print"[147] request analysis?"
  75. 4002 print" (press y[146] or n[146])"
  76. 4004 geta$:ifa$=""then4004
  77. 4006 ifa$<>"y"then5000
  78. 4008 print"[147] please wait..."
  79. 4009 b=7168:c=7678:d=2:tt=0:ct=0:hi=0:lo=65535:zz=0:g=256
  80. 4010 fora=btocstepd
  81. 4020 n=peek(a)+g*peek(a+1)
  82. 4030 ifn=0thenzz=zz+1:goto4040
  83. 4035 gosub4500
  84. 4040 next
  85. 4100 print"[147] random analysis:"
  86. 4110 print" total numbers hit:"
  87. 4120 print"   ";ct
  88. 4130 print" total count:"
  89. 4140 print"   ";tt
  90. 4150 print" average count:"
  91. 4160 print"   ";tt/ct
  92. 4170 print" lowest count:"
  93. 4180 print"   ";lo
  94. 4190 print" highest count:"
  95. 4200 print"   ";hi
  96. 4210 print" total zeroes:"
  97. 4220 print"   ";zz
  98. 4230 clr:print"r[146] to repeat analysis."
  99. 4240 geta$:ifa$=""then4240
  100. 4400 ifa$="r"then3000
  101. 4410 goto5000
  102. 4500 ct=ct+1:tt=tt+n
  103. 4510 ifn>hithenhi=n
  104. 4520 ifn<lothenlo=n
  105. 4530 return
  106. 5000 print"[147] program ended."
  107.